package com.hpf.lease.web.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.ViewAppointment;
import com.hpf.lease.web.admin.dto.AppointSearchSubmitDto;
import com.hpf.lease.web.admin.service.ViewAppointmentService;
import com.hpf.lease.web.admin.vo.AppointmentVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/appointment")
@Tag(name = "预约管理模块")
public class AppointmentController {
    @Resource
    ViewAppointmentService viewAppointmentService;
    @PostMapping("/updateStatusById")
    @Operation(summary = "根据id更新预约状态")
    public Result<Object> updateStatusById(@RequestParam long id ,
                                           @RequestParam String status){
        return Result.build(viewAppointmentService.update(Wrappers.lambdaUpdate(ViewAppointment.class)
                .eq(ViewAppointment::getId , id)
                .set(ViewAppointment::getAppointmentStatus , status)));
    }
    @GetMapping("/page")
    @Operation(summary = "分页查询预约信息")
    public Result<Page<AppointmentVo>> getPage(AppointSearchSubmitDto submitDto){
        return Result.ok(viewAppointmentService.getPage(submitDto));
    }
}
